﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace VM.Common.EntityEnum
{
    public class EnumManager
    {
        public static string GetJobStatusRemark(int oValue)
        {
            JobStatusEnum jobStatusEnum = (JobStatusEnum)oValue;
            FieldInfo fileInfo = typeof(JobStatusEnum).GetField(jobStatusEnum.ToString());

            if (fileInfo != null && fileInfo.IsDefined(typeof(RemarkAttribute), true))
            {
                RemarkAttribute attribute = fileInfo.GetCustomAttribute<RemarkAttribute>();
                return attribute.GetRemark();
            }
            return jobStatusEnum.ToString();
        }
        /// <summary>
        /// 单据状态
        /// </summary>
        /// <param name="billStatus"></param>
        /// <returns></returns>
        public static string GetBillStatusRemark(int billStatus)
        {

            if (billStatus == (int)BillstatusEnum.created)
            {
                return "创建";
            }
            else if (billStatus == (int)BillstatusEnum.check)
            {
                return "审核";
            }
            else if (billStatus == (int)BillstatusEnum.auditing)
            {
                return "审批中";
            }
            else if (billStatus == (int)BillstatusEnum.auditRejectToUpper)
            {
                return "驳回到上一级";

            }
            else if (billStatus == (int)BillstatusEnum.auditRejectToCreate)
            {
                return "驳回到发起人";
            }
            else if (billStatus == (int)BillstatusEnum.auditAgree)
            {
                return "审批通过";
            }
            else if (billStatus == (int)BillstatusEnum.auditReject)
            {
                return "审批拒绝";
            }
            else if (billStatus == (int)BillstatusEnum.forbidden)
            {
                return "禁用";
            }

            else
            {
                return "未设置";

            }
             
        }
        /// <summary>
        /// 性别
        /// </summary>
        /// <param name="Sex"></param>
        /// <returns></returns>
        public static string GetSexRemark(int? Sex)
        {

            if (Sex == 1)
            {
                return "男";
            }
            else if (Sex == 2)
            {
                return "女";
            }
            else if (Sex == 3)
            {
                return "保密";
            }
            else
            {
                return "未设置";

            }

        }
    }

   
}

public class RemarkAttribute : Attribute
    {
        private string _ReMark = string.Empty;
        public RemarkAttribute(string remark)
        {
            _ReMark = remark;
        }

        public string GetRemark() => _ReMark;
    }


